#include "TextureUnitState.h"

namespace Engine
{


CTextureUnitState::CTextureUnitState(const std::string& name/*=""*/, CTexture* pTexture/*=NULL*/):
	m_name(name),
	m_pTexture(pTexture),
	m_textureAddressMode(D3DTADDRESS_WRAP),
	m_colorOpEnable(true),
	m_alphaOpEnable(false)
{

}


CTextureUnitState::~CTextureUnitState(void)
{
}

void CTextureUnitState::SetTexture(CTexture* pTexture)
{
	m_pTexture = pTexture;
}

void CTextureUnitState::SetTextureAdress(D3DTEXTUREADDRESS address)
{
	m_textureAddressMode = address;
}

void CTextureUnitState::SetColourOperation(D3DTEXTUREOP op, \
	DWORD source1/* =D3DTA_TEXTURE */, DWORD source2 /* = D3DTA_CURRENT */)
{
	SetColourOperation(LayerTextureOp(op, source1, source2));
}

void CTextureUnitState::SetColourOperation(const LayerTextureOp& colorOp)
{
	m_textureOp = colorOp;
}

void CTextureUnitState::SetColourOpEnable(bool isEnable)
{
	m_colorOpEnable = isEnable;
}

void  CTextureUnitState::SetAlphaOperation(D3DTEXTUREOP op, \
	DWORD source1/*=D3DTA_TEXTURE*/, DWORD source2 /*= D3DTA_CURRENT*/)
{
	SetAlphaOperation(LayerTextureOp(op, source1, source2));
}

void  CTextureUnitState::SetAlphaOperation(const LayerTextureOp& alphaOp)
{
	m_alphaOp = alphaOp;
}

void CTextureUnitState::SetAlphaOpEnable(bool isEnable)
{
	m_alphaOpEnable = isEnable;
}

void CTextureUnitState::AddTextureStageStates(D3DTEXTURESTAGESTATETYPE stageType, DWORD vaule)
{
	m_textureStageStates.push_back(std::pair<D3DTEXTURESTAGESTATETYPE, DWORD>(stageType, vaule));
}


}
